//
//  CYYServiceViewController.m
//  NewPro
//
//  Created by RYX on 2019/3/19.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "CYYServiceViewController.h"
#import "KFChatViewController.h"
#import "KFCategorieListViewController.h"
#import "KFCreateTicketViewController.h"
#import "KFTicketListViewController.h"
#import "UINavigationBar+handle.h"

@interface CYYServiceViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,copy) NSArray *titleArr;
@property (nonatomic,copy) NSArray *imgArr;
@end

@implementation CYYServiceViewController

- (NSArray *)titleArr{
 
    if (!_titleArr) {
        
        _titleArr = @[@"帮助中心",@"提交反馈",@"查看反馈",@"联系客服"];
    }
    
    return _titleArr;
}

- (NSArray *)imgArr{
    
    if (!_imgArr) {
        
        _imgArr = @[@"icon_document",@"icon_request",@"icon_ticketList",@"icon_chat"];
    }
    
    return _imgArr;
}

- (UITableView *)tableView{
    
    if (!_tableView) {
        
        _tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
        _tableView.backgroundColor = [UIColor clearColor];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorInset = UIEdgeInsetsZero;
//        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 10)];
//        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
    }
    
    return _tableView;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    [self.navigationController.navigationBar navBarBackGroundColor:BLUECOLOR image:nil isOpaque:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNavBarWithTitle:@"在线客服"];
    
    [self.view addSubview:self.tableView];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.view);
    }];
}


#pragma mark - UITableViewDelegate,UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 55;
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.titleArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [[UITableViewCell alloc] init];;
    cell.textLabel.text = self.titleArr[indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:15];
    cell.imageView.image = [UIImage imageNamed:self.imgArr[indexPath.row]];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    switch (indexPath.row) {
        case 0:
            
            [self goHelpCenter];
            break;
        case 1:
            
            [self goSubmitFeedback];
            break;
        case 2:
            
            [self goLookFeedback];
            break;
        case 3:
            
            [self goStaffService];
            break;
        default:
            break;
    }
}

#pragma mark - 跳转帮助中心
- (void)goHelpCenter{
    
    [self.navigationController pushViewController:[[KFCategorieListViewController alloc] init] animated:YES];
}

#pragma mark - 跳转提交反馈
- (void)goSubmitFeedback{
    
    [self.navigationController pushViewController:[[KFCreateTicketViewController alloc] init] animated:YES];

}

#pragma mark - 跳转查看反馈
- (void)goLookFeedback{
    
    [self.navigationController pushViewController:[[KFTicketListViewController alloc] init] animated:YES];
}

#pragma mark - 跳转人工客服
- (void)goStaffService{
    
    KFChatViewController *chat = [[KFChatViewController alloc]initWithMetadata:@[]];
    chat.isHideRightButton = YES;
    [[AppDelegate sharedAppDelegate] pushViewController:chat];
}

@end
